package com.makeunion.gdlbsdemo.activity;

import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.amap.api.maps.AMap;
import com.amap.api.maps.MapView;
import com.amap.api.maps.model.Arc;
import com.amap.api.maps.model.ArcOptions;
import com.amap.api.maps.model.BitmapDescriptor;
import com.amap.api.maps.model.BitmapDescriptorFactory;
import com.amap.api.maps.model.Circle;
import com.amap.api.maps.model.CircleOptions;
import com.amap.api.maps.model.CrossOverlay;
import com.amap.api.maps.model.CrossOverlayOptions;
import com.amap.api.maps.model.LatLng;
import com.amap.api.maps.model.NavigateArrow;
import com.amap.api.maps.model.NavigateArrowOptions;
import com.amap.api.maps.model.Polygon;
import com.amap.api.maps.model.PolygonOptions;
import com.amap.api.maps.model.Polyline;
import com.amap.api.maps.model.PolylineOptions;
import com.makeunion.gdlbsdemo.R;

import java.util.ArrayList;
import java.util.List;

/**
 * 类说明
 *
 * @author renjialiang
 * @version [版本]
 * @see [相关类]
 * @since [模块]
 */
public class MarkSurfaceActivity extends AppCompatActivity {

    private MapView mapView;

    private AMap aMap;

    public static final LatLng BEIJING = new LatLng(39.90403, 116.407525);// 北京
    public static final LatLng BEIJING_NEXT = new LatLng(38.90403, 114.407525);// 北京
    public static final LatLng SHANGHAI = new LatLng(31.238068, 121.501654);// 上海
    public static final LatLng CHENGDU = new LatLng(30.679879, 104.064855);// 成都

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mark_surface);

        mapView = (MapView) findViewById(R.id.map_view);
        mapView.onCreate(savedInstanceState); //此方法必须重写
        init();
    }

    private void init() {
        if (aMap == null) {
            aMap = mapView.getMap();
        }
    }

    public void drawCircle(View view) {
        CircleOptions circleOptions = new CircleOptions();
        circleOptions
                .center(BEIJING)
                .radius(10000)
                .fillColor(Color.argb(50, 0, 0, 0))
                .strokeColor(Color.argb(200, 0, 0, 0))
                .strokeWidth(4);

        Circle circle = aMap.addCircle(circleOptions);
    }

    public void drawArc(View view) {
        ArcOptions arcOptions = new ArcOptions();
        arcOptions.point(BEIJING, SHANGHAI, CHENGDU)
                .strokeWidth(4)
                .strokeColor(Color.argb(250, 0, 200, 50));

        Arc arc = aMap.addArc(arcOptions);
    }

    public void drawNavigationArrow(View view) {
        NavigateArrowOptions navigateArrowOptions = new NavigateArrowOptions();
        navigateArrowOptions
                .add(BEIJING)
                .add(BEIJING_NEXT)
                .topColor(Color.BLUE);

        NavigateArrow navigateArrow = aMap.addNavigateArrow(navigateArrowOptions);
    }

    public void drawPolygon(View view) {
        PolygonOptions polygonOptions = new PolygonOptions();
        polygonOptions
                .add(BEIJING)
                .add(SHANGHAI)
                .add(CHENGDU)
                .strokeWidth(4)
                .fillColor(Color.argb(50, 250, 0, 0))
                .strokeColor(Color.argb(250, 0, 0, 0));

        Polygon polygon = aMap.addPolygon(polygonOptions);
    }

    @Override
    protected void onResume() {
        super.onResume();
        mapView.onResume();
    }

    /**
     * 方法必须重写
     */
    @Override
    protected void onPause() {
        super.onPause();
        mapView.onPause();
    }

    /**
     * 方法必须重写
     */
    @Override
    protected void onDestroy() {
        super.onDestroy();
        mapView.onDestroy();
    }

    /**
     * 方法必须重写
     */
    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        mapView.onSaveInstanceState(outState);
    }
}
